package com.liujit.upms.controller;

import com.liujit.common.domain.params.DelParams;
import com.liujit.common.domain.result.PageBean;
import com.liujit.upms.domain.params.SysLogParams;
import com.liujit.upms.domain.query.SysLogQuery;
import com.liujit.upms.domain.result.SysLogResult;
import com.liujit.upms.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 系统日志管理接口
 * @Author liujun
 * @Date 2021-06-26 15:45:43
 */
@RequiredArgsConstructor
@Api(tags = "系统日志管理接口")
@RestController
@RequestMapping("/sys/log")
public class SysLogController {

    private final SysLogService sysLogService;

    @ApiOperation(value = "分页查询操作日志", notes = "根据系统日志分页查询条件，分页查询系统字典数据列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "系统日志分页查询条件", dataType = "SysLogQuery", dataTypeClass = SysLogQuery.class, paramType = "query") })
    @GetMapping("/getOperationPage")
    public PageBean<SysLogResult> getOperationPage(SysLogQuery query) {
        return sysLogService.getOperationPage(query);
    }

    @ApiOperation(value = "分页查询异常日志", notes = "根据系统日志分页查询条件，分页查询系统字典数据列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "系统日志分页查询条件", dataType = "SysLogQuery", dataTypeClass = SysLogQuery.class, paramType = "query") })
    @GetMapping("/getExceptionPage")
    public PageBean<SysLogResult> getExceptionPage(SysLogQuery query) {
        return sysLogService.getExceptionPage(query);
    }

    @ApiOperation(value = "查询操作日志", notes = "根据系统日志id，查询系统日志")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "系统日志id", dataType = "Long", dataTypeClass = Long.class, paramType = "query") })
    @GetMapping("/getOperation")
    public SysLogResult getOperation(Long id) {
        return sysLogService.get(id);
    }

    @ApiOperation(value = "查询异常日志", notes = "根据系统日志id，查询系统日志")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "系统日志id", dataType = "Long", dataTypeClass = Long.class, paramType = "query") })
    @GetMapping("/getException")
    public SysLogResult getException(Long id) {
        return sysLogService.get(id);
    }

    @ApiOperation(value = "删除", notes = "根据系统日志删除请求参数，删除系统字典数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "系统字典数据删除请求参数", dataType = "DelParams", dataTypeClass = DelParams.class, paramType = "body") })
    @PostMapping("/delOperation")
    public Boolean delOperation(@RequestBody DelParams params) {
        return sysLogService.del(params);
    }

    @ApiOperation(value = "删除", notes = "根据系统日志删除请求参数，删除系统字典数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "系统字典数据删除请求参数", dataType = "DelParams", dataTypeClass = DelParams.class, paramType = "body") })
    @PostMapping("/delException")
    public Boolean delException(@RequestBody DelParams params) {
        return sysLogService.del(params);
    }

    @ApiOperation(value = "添加", notes = "根据系统日志添加请求参数，添加系统字典数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", value = "系统日志添加请求参数", dataType = "SysLogParam", dataTypeClass = SysLogParams.class, paramType = "body") })
    @PostMapping("/add")
    public Boolean add(@RequestBody SysLogParams param) {
        return sysLogService.add(param);
    }
}
